<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh">
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>
<head>
    <meta charset="utf-8" />
    <title>保险代理后台管理系统</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
    <jsp:include page="../common/header.jsp"></jsp:include>
    <%@include file="../common/taglib.jsp"%>

    <!-- ================== 单独作用于本页表格td ================== -->
    <style>
    </style>
    <!-- ================== 单独作用于本页表格td ================== -->

</head>
<body>
<!-- begin #page-loader -->
<div id="page-loader" class="fade in"><span class="spinner"></span></div>
<!-- end #page-loader -->

<!-- begin #page-container -->
<div id="page-container" class="fade page-sidebar-fixed page-header-fixed">
    <jsp:include page="../common/top.jsp"/>

    <!-- begin #sidebar -->
    <jsp:include page="../common/sitebar.jsp"/>
    <div class="sidebar-bg"></div>
    <!-- end #sidebar -->
    <!-- begin #content -->
    <div id="content" class="content">
        <!-- begin row -->
        <div class="row">
            <div class="col-md-12">
                <ul id ="repayTabs" class="nav nav-tabs">
                    <shiro:hasPermission name="order:repaying:company">
                    <li id="firstTab" class="active"><a href="#default-tab-1" data-toggle="tab" onclick="changeUrl(1)">保险公司</a></li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="order:repaying:channel">
                    <li id="secondTab" class=""><a href="#default-tab-2" data-toggle="tab" onclick="changeUrl(2)">渠道</a></li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="repaying:company:down">
                        <li class="link-down">
                            <span onclick="openModel(1)" id="down">
                                <i class="fa fa-download fa-2"></i>下载列表
                            </span>
                        </li>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="repaying:channel:down">
                        <li class="link-down hidden">
                            <span onclick="openModel(2)" id="down1">
                                <i class="fa fa-download fa-2"></i>下载列表
                            </span>
                        </li>
                    </shiro:hasPermission>
                </ul>
                <div class="tab-content">
                    <shiro:hasPermission name="order:repaying:company">
                    <div class="tab-pane fade active in" id="default-tab-1">
                        <div>
                            <form class="form-horizontal">

                                <div class="form-group">
                                    <label class="col-md-1 control-label" style="width: 78px;">保险公司:</label>
                                    <div class="col-md-2">
                                        <select id="insyrerIdSerch" class="form-control">
                                            <option value="">全部</option>
                                            <c:forEach items="${insurerList}" var="isl">
                                                <option value="${isl.tid}">${isl.name}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                    <label class="col-md-1 control-label">出单日期:</label>
                                    <div class="col-md-3">
                                        <div class="input-group input-daterange">
                                            <input type="text" class="form-control datepicker-default" id="dateIssuanceStartSerch" placeholder="开始日期" />
                                            <span class="input-group-addon">至</span>
                                            <input type="text" class="form-control datepicker-default" id="dateIssuanceEndSerch" placeholder="结束日期"/>
                                        </div>
                                    </div>
                                    <label class="col-md-1 control-label">保单号:</label>
                                    <div class="col-md-2">
                                        <input type="text" id="ordNumSerch"  class="form-control" placeholder="保单号" />
                                    </div>
                                </div>
                                <div class="form-group" style="margin-bottom:4px;">
                                    <label class="col-md-1 control-label" style="width: 78px;">渠道:</label>
                                    <%--<div class="col-md-2">
                                        <select class="form-control selectpicker" id="channelIdSerch" data-size="10" data-live-search="true" data-style="btn-white">
                                            <option value="">全部</option>
                                            <c:forEach items="${channels}" var="cl">
                                                <option value="${cl.tid}">${cl.contact.name}</option>
                                            </c:forEach>
                                        </select>
                                    </div>--%>
                                    <div class="col-md-2">
                                        <input type="hidden" name="channelIdSerch" id="channelIdSerch">
                                        <input type="text" id="channelNameSerch" name="channelNameSerch" data-toggle="dropdown"  class="form-control dropdown-toggle" placeholder="渠道" />
                                        <ul id="chs" class="dropdown-menu" style="max-height: 200px;overflow: auto;margin-left: 15px;">
                                        </ul>
                                    </div>
                                    <label class="col-md-1 control-label">退保日期:</label>
                                    <div class="col-md-3">
                                        <div class="input-group input-daterange">
                                            <input type="text" class="form-control datepicker-default" id="surrenderDateStartSerch" placeholder="开始日期" />
                                            <span class="input-group-addon">至</span>
                                            <input type="text" class="form-control datepicker-default" id="surrenderDateEndSerch" placeholder="结束日期"/>
                                        </div>
                                    </div>
                                    <div class="col-md-3" style="margin-left:-15px;">
                                        <button type="button" onclick="search1()" class="btn btn-primary m-r-5 m-b-5">查询</button>
                                    </div>
                                </div>
                            </form>
                            <div class="table-responsive" >
                                <table id="insurerTable" class="table table-striped table-bordered" style= "word-break:break-all;word-wrap:break-word">
                                    <thead>
                                    <tr>
                                        <th width="6%">保单号</th>
                                        <th width="6%">付款主体</th>
                                        <th width="6%">保险公司</th>
                                        <th width="6%">渠道</th>
                                        <th width="6%">渠道联系电话</th>
                                        <th width="6%">险种</th>
                                        <th width="6%">被保险人</th>
                                        <th width="6%">被保险人证件号</th>
                                        <th width="6%">车牌号</th>
                                        <th width="6%">商业保险费（元）</th>
                                        <th width="6%">交强保险费（元）</th>
                                        <th width="6%">车船税（元）</th>
                                        <th width="6%">全保费（元）</th>
                                        <th width="6%">跟单点位</th>
                                        <th width="6%">补点点位</th>
                                        <th width="6%">退保扣除手续费（元）</th>
                                        <th width="6%">下单日期</th>
                                        <th width="6%">起保日期</th>
                                        <th width="6%">退保日期</th>
                                        <th width="6%">操作</th>
                                    </tr>
                                    </thead>
                                </table>
                            </div>
                        </div>
                    </div>
                    </shiro:hasPermission>
                    <shiro:hasPermission name="order:repaying:channel">
                    <div class="tab-pane fade" id="default-tab-2">
                        <div>
                            <form class="form-horizontal">

                                <div class="form-group">
                                    <label class="col-md-1 control-label" style="width: 78px;">保险公司:</label>
                                    <div class="col-md-2">
                                        <select id="insyrerIdCSerch" class="form-control">
                                            <option value="">全部</option>
                                            <c:forEach items="${insurerList}" var="isl">
                                                <option value="${isl.tid}">${isl.name}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                    <label class="col-md-1 control-label">出单日期:</label>
                                    <div class="col-md-3">
                                        <div class="input-group input-daterange">
                                            <input type="text" class="form-control datepicker-default" id="dateIssuanceStartCSerch" placeholder="开始日期" />
                                            <span class="input-group-addon">至</span>
                                            <input type="text" class="form-control datepicker-default" id="dateIssuanceEndCSerch" placeholder="结束日期"/>
                                        </div>
                                    </div>
                                    <label class="col-md-1 control-label">保单号:</label>
                                    <div class="col-md-2">
                                        <input type="text" id="ordNumCSerch"  class="form-control" placeholder="保单号" />
                                    </div>
                                </div>
                                <div class="form-group" style="margin-bottom:4px;">
                                    <label class="col-md-1 control-label" style="width: 78px;">渠道:</label>
                                    <div class="col-md-2">
                                        <%--<select class="form-control selectpicker" id="channelIdCSerch" data-size="10" data-live-search="true" data-style="btn-white">
                                            <option value="">全部</option>
                                            <c:forEach items="${channels}" var="cl">
                                                <option value="${cl.tid}">${cl.contact.name}</option>
                                            </c:forEach>
                                        </select>--%>
                                        <input type="hidden" name="channelIdCSerch" id="channelIdCSerch">
                                        <input type="text" id="channelNameCSerch" name="channelNameCSerch" data-toggle="dropdown"  class="form-control dropdown-toggle" placeholder="渠道" />
                                        <ul id="chc" class="dropdown-menu" style="max-height: 200px;overflow: auto;margin-left: 15px;">
                                        </ul>
                                    </div>

                                    <label class="col-md-1 control-label">退保日期:</label>
                                    <div class="col-md-3">
                                        <div class="input-group input-daterange">
                                            <input type="text" class="form-control datepicker-default" id="surrenderDateStartCSerch" placeholder="开始日期" />
                                            <span class="input-group-addon">至</span>
                                            <input type="text" class="form-control datepicker-default" id="surrenderDateEndCSerch" placeholder="结束日期"/>
                                        </div>
                                    </div>
                                    <div class="col-md-3" style="margin-left:-15px;">
                                        <button type="button" onclick="search2()" class="btn btn-primary m-r-5 m-b-5">查询</button>
                                    </div>
                                </div>
                            </form>
                            <div class="table-responsive" >
                                <table id="channelTable" class="table table-striped table-bordered" style= "word-break:break-all;word-wrap:break-word">
                                    <thead>
                                    <tr>
                                        <th width="6%">保单号</th>
                                        <th width="6%">付款主体</th>
                                        <th width="6%">保险公司</th>
                                        <th width="6%">渠道</th>
                                        <th width="6%">渠道联系电话</th>
                                        <th width="6%">险种</th>
                                        <th width="6%">被保险人</th>
                                        <th width="6%">被保险人证件号</th>
                                        <th width="6%">车牌号</th>
                                        <th width="6%">商业保险费（元）</th>
                                        <th width="6%">交强保险费（元）</th>
                                        <th width="6%">车船税（元）</th>
                                        <th width="6%">全保费（元）</th>
                                        <th width="6%">开单日期</th>
                                        <%--<th width="6%">保险公司收保费日期</th>--%>
                                        <th width="6%">起保日期</th>
                                        <th width="6%">渠道返点</th>
                                        <th width="6%">渠道返佣费</th>
                                        <th width="6%">应收保费（元）</th>
                                        <th width="6%">实收保费（元）</th>
                                        <th width="6%">渠道账期到期日</th>
                                        <th width="6%">退保日期</th>
                                        <th width="6%">退保应扣除渠道佣金（元）</th>
                                        <th width="6%">退保渠道应还保费（元）</th>
                                        <th width="6%">渠道退保结算金额（元）</th>
                                        <th width="6%">跟单员</th>
                                        <th width="6%">操作</th>
                                    </tr>
                                    </thead>
                                </table>
                            </div>
                        </div>
                    </div>
                    </shiro:hasPermission>
                    <div id="default-tab-3" class="tab-pane fade ">
                        <div id="iframeParent">
                            <iframe width="100%" height="100%" frameborder="0" id="iframe" scrolling="no"></iframe>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- end row -->
        <div class="modal fade" id="insurer-subInfo">
            <div class="modal-dialog">
                <div class="modal-content">
                    <form role="form" action="/repaying/addi" method="post" class="form-horizontal form-bordered" data-parsley-validate="true">

                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title">退保核对</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <label class="control-label col-md-4 col-sm-4">退保保险公司扣除手续费:</label>
                            <div class="col-md-6 col-sm-6">
                                <input type="hidden" class="form-control" id="iTid" name="tid" value="">
                                <input type="hidden" class="form-control" id="iCapitalTid" name="capitalTid" value="">
                                <input type="hidden" class="form-control" id="iOpponent" name="opponent" value="">
                                <input type="hidden" class="form-control" id="iTradeType" name="tradeType" value="">
                                <div class="input-group">
                                    <input type="text" class="form-control" id="amt1" name="payInsurerAmt"
                                           data-parsley-money="true"
                                           data-parsley-money-message="请输入9位以内的整数或小数且小数点后只有两位"
                                           data-parsley-required="true" data-parsley-required-message="请输入退保保险公司扣除手续费"/>
                                    <div class="input-group-addon">元</div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-4 col-sm-4">退保应扣除渠道佣金:</label>
                            <div class="col-md-6 col-sm-6">
                                <div class="input-group">
                                    <input type="text" class="form-control" id="amt2" name="mustRebateAmt"
                                           data-parsley-money="true"
                                           data-parsley-money-message="请输入9位以内的整数或小数且小数点后只有两位"
                                           data-parsley-required="true" data-parsley-required-message="请输入退保应扣除渠道佣金"/>
                                    <div class="input-group-addon">元</div>
                                </div>
                            </div>
                        </div>
                        <div id="insurer-mustPreInfo" class="form-group">
                            <label class="control-label col-md-4 col-sm-4">退保渠道应还保费:</label>
                            <div class="col-md-6 col-sm-6">
                                <div class="input-group">
                                    <input type="text" class="form-control" id="amt3" name="mustPremium"
                                           data-parsley-money="true"
                                           data-parsley-money-message="请输入9位以内的整数或小数且小数点后只有两位"
                                           data-parsley-required="true" data-parsley-required-message="请输入退保渠道应还保费"/>
                                    <div class="input-group-addon">元</div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-4 col-sm-4">起保日期:</label>
                            <div class="col-md-6 col-sm-6">
                                <input class="form-control" type="text" id="date1" disabled />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-4 col-sm-4">退保日期:</label>
                            <div class="col-md-6 col-sm-6">
                                <input class="form-control datepicker-default" type="text" id="date2" name="surrenderDateStart" data-parsley-required="true"
                                       data-parsley-required-message="不能为空" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-4 col-sm-4">备注：</label>
                            <div class="col-md-6 col-sm-6">
                                <textarea class="form-control" name="remark" data-parsley-required="true" value=""
                                          data-parsley-required-message="不能为空" maxlength="100" rows="4" ></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary">提  交</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">取  消</button>
                    </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="modal fade" id="channel-subInfo">
            <div class="modal-dialog">
                <div class="modal-content">
                    <form role="form" action="/repaying/addc" method="post" class="form-horizontal form-bordered" data-parsley-validate="true">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title">渠道退保结算</h4>
                    </div>
                        <div class="modal-body">
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">退保日期：</label>
                                <div class="col-md-6 col-sm-6">
                                    <input type="hidden" class="form-control" id="cTid" name="tid" value="">
                                    <input type="hidden" class="form-control" id="cChannelId" name="channelId" value="">
                                    <input type="hidden" class="form-control" id="cCapitalTid" name="capitalTid" value="">
                                    <input type="hidden" class="form-control" id="cOpponent" name="opponent" value="">
                                    <input type="hidden" class="form-control" id="cTradeType" name="tradeType" value="">
                                    <input class="form-control" id="cDate1" type="text" name="cDate1" disabled/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">退保应扣除渠道佣金：</label>
                                <div class="col-md-6">
                                    <div class="input-group">
                                        <input type="text" class="form-control" id="cAmt1" name="cAmt1" disabled
                                               data-parsley-money="true"
                                               data-parsley-money-message="请输入9位以内的整数或小数且小数点后只有两位"
                                               data-parsley-required="true" data-parsley-required-message="请输入退保应扣除渠道佣金"/>
                                        <div class="input-group-addon">元</div>
                                    </div>
                                </div>
                            </div>
                            <div id="channel-mustPreInfo" class="form-group">
                                <label class="control-label col-md-4 col-sm-4">退保渠道应还保费：</label>
                                <div class="col-md-6 col-sm-6">
                                    <div class="input-group">
                                    <input type="text" class="form-control" id="cAmt2" name="cAmt2" disabled
                                           data-parsley-money="true"
                                           data-parsley-money-message="请输入9位以内的整数或小数且小数点后只有两位"
                                           data-parsley-required="true" data-parsley-required-message="请输入退保应扣除渠道佣金"/>
                                    <div class="input-group-addon">元</div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">渠道退保保费：</label>
                                <div class="col-md-6">
                                    <div class="input-group">
                                        <input type="text" class="form-control" id="cAmt3" name="realPremium"
                                               data-parsley-money="true"
                                               data-parsley-money-message="请输入9位以内的整数或小数且小数点后只有两位"
                                               data-parsley-required="true" data-parsley-required-message="请输入退保渠道应还保费"/>
                                        <div class="input-group-addon">元</div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">渠道退保佣金：</label>
                                <div class="col-md-6 col-sm-6">
                                    <div class="input-group">
                                        <input type="text" class="form-control" id="cAmt4" name="realRebateAmt"
                                               data-parsley-money="true"
                                               data-parsley-money-message="请输入9位以内的整数或小数且小数点后只有两位"
                                               data-parsley-required="true" data-parsley-required-message="请输入渠道退保佣金"/>
                                        <div class="input-group-addon">元</div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">渠道扣费来源：</label>
                                <div class="col-md-6 col-sm-6">
                                    <select id="capitalSourcr" name="capitalSourcr" class="form-control">
                                        <option value="">请选择</option>
                                        <option value="1">正常结算</option>
                                        <option value="2">保证金</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">备注：</label>
                                <div class="col-md-6 col-sm-6">
                                <textarea class="form-control" name="remark" data-parsley-required="true" value=""
                                          data-parsley-required-message="不能为空" maxlength="100" rows="4"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="submit" class="btn btn-primary">提  交</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">取  消</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <div class="modal fade" id="modal-subInfo">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title">温馨提示</h4>
                    </div>
                    <div id="showSubInfo" class="modal-body">
                        当前填写内容未提交，确认取消？
                    </div>
                    <div class="modal-footer">
                        <a href="javascript:;" id="subButtonYes" class="btn btn-primary">确定</a>
                        <a href="javascript:;" id="subButtonNo" class="btn btn-default" data-dismiss="modal">取消</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <jsp:include page="../common/footer.jsp"/>
    <script>
        var dic = new Array();
        <c:forEach items="${dictionary}" var="d">
            var sa = [];
            sa[0]="${d.riskKey}";
            sa[1]= "${d.riskValue}";
            dic.push(sa);
        </c:forEach>
        $(document).ready(function() {
            App.init();
            TableManageFixedHeader.init();
            $('.datepicker-default').datepicker({
                language: 'zh-CN',//显示中文
                format: 'yyyy-mm-dd',//显示格式
                minView: "month",//设置只显示到月份
                initialDate: new Date(),//初始化当前日期
                autoclose: true,//选中自动关闭
                todayBtn: 'linked'//显示今日按钮
            });
            $('.selectpicker').selectpicker({
                style: 'btn-white',
                size: 5
            });
            <c:if test="${type=='C'}">
            $("#firstTab").removeClass("active");
            $("#secondTab").addClass("active in");
            $("#default-tab-1").removeClass("active in");
            $("#default-tab-2").addClass("active in");
            </c:if>
        });
        //数字  小数点  限制小数点前9位 小数点后两位
        window.ParsleyValidator.addValidator('money', function(value) {
            if(value!= ""){
                return /^([1-9]\d{0,8})$|^([1-9]\d{0,8}\.\d{1,2})$/.test(value);

            }
            return true;
        },32);
        function insurerShow(amt1,amt2,amt3,date1,date2,tid,ctid,type1,type2,type,cstatus) {
            $("#amt1").val("");
            $("#amt2").val("");
            $("#amt3").val("");
            $("#date1").val("");
            $("#date2").val("");
            $("#iTid").val("");
            $("#iCapitalTid").val("");
            $("#iOpponent").val("");
            $("#iTradeType").val("");
            $("#amt1").val(amt1);
            $("#amt2").val(amt2);
            $("#amt3").val(amt3);
            $("#date1").val(date1.substring(0,10));
            $("#date2").val(date2.substring(0,10));
            $("#iTid").val(tid);
            $("#iCapitalTid").val(ctid);
            $("#iOpponent").val(type1);
            $("#iTradeType").val(type2);
            $("#insurer-mustPreInfo").show();
            if(3==type && 5==cstatus){
                $("#amt3").val("0");
                $("#insurer-mustPreInfo").hide();
            }
            $("#insurer-subInfo").modal('show');
        }
        function channelShow(date1,amt1,amt2,tid,ctid,cctid,type,cstatus,status,type1,type2) {
            $("#cAmt1").val("");
            $("#cAmt2").val("");
            $("#cAmt3").val("");
            $("#cAmt4").val("");
            $("#cDate1").val("");
            $("#cTid").val("");
            $("#cChannelId").val("");
            $("#cCapitalTid").val("");
            $("#cOpponent").val("");
            $("#cTradeType").val("");
            $("#cAmt1").val(amt1);
            $("#cAmt2").val(amt2);
            $("#cAmt3").val(amt1);
            $("#cAmt4").val(amt2);
            $("#cDate1").val(date1.substring(0,10));
            $("#cTid").val(tid);
            $("#cChannelId").val(cctid);
            $("#cCapitalTid").val(ctid);
            $("#cOpponent").val(type1);
            $("#cTradeType").val(type2);
            $("#capitalSourcr").html("");
            if(6==status){//授信通过的
                $("#capitalSourcr").append("<option value='1'>正常结算</option>");
                $("#capitalSourcr").append("<option value='2'>保证金</option>");
            }else{
                $("#capitalSourcr").append("<option value='1'>正常结算</option>");
            }
            if(3==type && 5==cstatus){
                $("#channel-mustPreInfo").hide();
            }
            $("#channel-subInfo").modal('show');
        }
        var table1;
        $(document).ready(function() {
            table1 = $("#insurerTable").DataTable({
                "pagingType": "simple_numbers",//设置分页控件的模式
                searching: false,//屏蔽datatales的查询框
                aLengthMenu:[15],//设置一页展示10条记录
                "bLengthChange": false,//屏蔽tables的一页展示多少条记录的下拉列表
                "ordering": false,
                "oLanguage": {  //对表格国际化
                    "sLengthMenu": "每页显示 _MENU_条",
                    "sZeroRecords": "无匹配结果，请更换筛选条件再试",
                    //  "sProcessing": "&lt;img src=’./loading.gif’ /&gt;",
                    "sInfo": "当前第 _START_ - _END_ 条　共计 _TOTAL_ 条",
                    "sInfoEmpty": "当前第 0 - 0 条　共计 0 条",
                    "sInfoFiltered": "(从 _MAX_ 条记录中过滤)",
                    "sSearch": "搜索：",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "前一页",
                        "sNext": "后一页",
                        "sLast": "尾页"

                    }
                },
                //"processing": true, //打开数据加载时的等待效果
                "serverSide": true,//打开后台分页
                /*"order": [[ 18, "desc" ]],*/
                "ajax": {
                    "url": "/repaying/queryInsurerData",
                    "dataSrc": "aaData",
                    "data": function ( d ) {
                        var insyrerId = $('#insyrerIdSerch').val();
                        var ordNum = $('#ordNumSerch').val();
                        var channelId = $('#channelIdSerch').val();
                        var dateIssuanceStart = $('#dateIssuanceStartSerch').val();
                        var dateIssuanceEnd = $('#dateIssuanceEndSerch').val();
                        var surrenderDateStart = $('#surrenderDateStartSerch').val();
                        var surrenderDateEnd = $('#surrenderDateEndSerch').val();
                        //添加额外的参数传给服务器
                        d.capitalStatus = 1;
                        d.insyrerId = insyrerId;
                        d.ordNum = ordNum;
                        d.channelId = channelId;
                        d.dateIssuanceStart = dateIssuanceStart;
                        d.dateIssuanceEnd = dateIssuanceEnd;
                        d.surrenderDateStart = surrenderDateStart;
                        d.surrenderDateEnd = surrenderDateEnd;
                    }
                },
                "columns": [
                    { "data": "ordNum","defaultContent": "--","bSortable": false},
                    { "data": "paySubject" ,"defaultContent": "--","bSortable": false},
                    { "data": "insyrerName","defaultContent": "--","bSortable": false},
                    { "data": "channelPName","defaultContent": "--","bSortable": false},
                    { "data": "channelPhone" ,"defaultContent": "--","bSortable": false},
                    { "data": "typeInsurance" ,"defaultContent": "--","bSortable": false},
                    { "data": "insurant" ,"defaultContent": "--","bSortable": false},
                    { "data": "orgIdCode" ,"defaultContent": "--","bSortable": false},
                    { "data": "plateNum" ,"defaultContent": "--","bSortable": false},
                    { "data": "mercialPremium" ,"defaultContent": "--",sClass: "text-right","bSortable": false},
                    { "data": "pulsoryPremium" ,"defaultContent": "--",sClass: "text-right","bSortable": false},
                    { "data": "vechcleVesselTax" ,"defaultContent": "--",sClass: "text-right","bSortable": false},
                    { "data": "allPremium" ,"defaultContent": "--",sClass: "text-right","bSortable": false},
                    { "data": "followPoint" ,"defaultContent": "--","bSortable": false},
                    { "data": "replenishPoint" ,"defaultContent": "--","bSortable": false},
                    { "data": "payInsurerAmt","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "createDate" ,"defaultContent": "--","bSortable": false},
                    { "data": "datePolicy" ,"defaultContent": "--","bSortable": false},
                    { "data": "surrenderDate" ,"defaultContent": "--","bSortable": false}

                ],

                "columnDefs" : [ {
                    // 定义操作列,######以下是重点########
                    "targets" : 19,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var id = '"' + row.tid + '"';
                        var html = "";
                        <shiro:hasPermission name="repaying:company:check">
                        html +=  "<a href='javascript:void(0);' onclick='insurerShow("+ row.payInsurerAmt + ","+ row.mustRebateAmt + ","+ row.mustPremium + ",\""+ row.insureStartDate + "\",\""+ row.surrenderDate + "\",\""+ row.tid + "\",\""+ row.capitalTid + "\",\""+ row.opponent + "\",\""+ row.tradeType + "\",\""+ row.typeInsurance2 + "\",\""+ row.capitalChannelStatus + "\")' class='btn-link'>退保核对</a>&nbsp;&nbsp;&nbsp;&nbsp;"
                        </shiro:hasPermission>

                        return html;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 5,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var type =  row.typeInsurance;
                        var html = "商业险";
                        if('0'==type){
                            html = "交强险";
                        }
                        return html;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 3,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var type =  row.channelType;
                        var html =  row.channelCName;
                        if('1'==type){
                            html = row.channelPName;
                        }
                        return html;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 0,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var ordNum =  row.ordNum;
                        var id = '"' + row.tid + '"';
                        var html = "<a href='javascript:void(0);'   onclick='detail("+ id + ")'  class='btn-link'>"+row.ordNum+"</a>"
                        return html;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 1,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var type =  ""+row.paySubject;
                        var html = "--";
                        for(var i=0;i<dic.length;i++){
                            var dics = ""+dic[i][0];
                            if(type==dics){
                                html = dic[i][1];
                            }
                        }
                        return html;
                    }
                }]

            } );
        } );
        var table2;
        $(document).ready(function() {
            table2 = $("#channelTable").DataTable( {
                "pagingType": "simple_numbers",//设置分页控件的模式
                searching: false,//屏蔽datatales的查询框
                aLengthMenu:[15],//设置一页展示10条记录
                "ordering": false,
                "bLengthChange": false,//屏蔽tables的一页展示多少条记录的下拉列表
                "oLanguage": {  //对表格国际化
                    "sLengthMenu": "每页显示 _MENU_条",
                    "sZeroRecords": "无匹配结果，请更换筛选条件再试",
                    //  "sProcessing": "&lt;img src=’./loading.gif’ /&gt;",
                    "sInfo": "当前第 _START_ - _END_ 条　共计 _TOTAL_ 条",
                    "sInfoEmpty": "当前第 0 - 0 条　共计 0 条",
                    "sInfoFiltered": "(从 _MAX_ 条记录中过滤)",
                    "sSearch": "搜索：",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "前一页",
                        "sNext": "后一页",
                        "sLast": "尾页"

                    }
                },
                //"processing": true, //打开数据加载时的等待效果
                "serverSide": true,//打开后台分页
                /*"order": [[ 23, "desc" ]],*/
                "ajax": {
                    "url": "/repaying/queryInsurerData",
                    "dataSrc": "aaData",
                    "data": function ( d ) {
                        var insyrerId = $('#insyrerIdCSerch').val();
                        var ordNum = $('#ordNumCSerch').val();
                        var channelId = $('#channelIdCSerch').val();
                        var dateIssuanceStart = $('#dateIssuanceStartCSerch').val();
                        var dateIssuanceEnd = $('#dateIssuanceEndCSerch').val();
                        var surrenderDateStart = $('#surrenderDateStartCSerch').val();
                        var surrenderDateEnd = $('#surrenderDateEndCSerch').val();
                        //添加额外的参数传给服务器
                        d.capitalStatus = 3;
                        d.insyrerId = insyrerId;
                        d.ordNum = ordNum;
                        d.channelId = channelId;
                        d.dateIssuanceStart = dateIssuanceStart;
                        d.dateIssuanceEnd = dateIssuanceEnd;
                        d.surrenderDateStart = surrenderDateStart;
                        d.surrenderDateEnd = surrenderDateEnd;
                    }
                },
                "columns": [
                    { "data": "ordNum","defaultContent": "--","bSortable": false},
                    { "data": "paySubject" ,"defaultContent": "--","bSortable": false},
                    { "data": "insyrerName","defaultContent": "--","bSortable": false},
                    { "data": "channelPName","defaultContent": "--","bSortable": false},
                    { "data": "channelPhone" ,"defaultContent": "--","bSortable": false},
                    { "data": "typeInsurance" ,"defaultContent": "--","bSortable": false},
                    { "data": "insurant" ,"defaultContent": "--","bSortable": false},
                    { "data": "orgIdCode" ,"defaultContent": "--","bSortable": false},
                    { "data": "plateNum" ,"defaultContent": "--","bSortable": false},
                    { "data": "mercialPremium","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "pulsoryPremium","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "vechcleVesselTax","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "allPremium","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "dateIssuance" ,"defaultContent": "--","bSortable": false},
                    { "data": "datePolicy" ,"defaultContent": "--","bSortable": false},
                    { "data": "channelRebate" ,"defaultContent": "--","bSortable": false},
                    { "data": "insureMustRebateAmt","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "insureMustPremium","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "insureRealPremium","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "insyrerMaturityDate","defaultContent": "--" ,"bSortable": false},
                    { "data": "surrenderDate" ,"defaultContent": "--","bSortable": false},
                    { "data": "mustRebateAmt","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "mustPremium","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "realRebateAmt","defaultContent": "--",sClass: "text-right" ,"bSortable": false},
                    { "data": "salemanName" ,"defaultContent": "--","bSortable": false}

                ],

                "columnDefs" : [ {
                    // 定义操作列,######以下是重点########
                    "targets" : 25,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var id = '"' + row.tid + '"';
                        var html = "";
                        <shiro:hasPermission name="repaying:channel:settle">
                        html =  "<a href='javascript:void(0);' onclick='channelShow(\""+ row.insureStartDate + "\","+ row.mustPremium + ","+ row.mustRebateAmt+ ",\""+ row.tid + "\",\""+ row.capitalTid + "\",\""+ row.channelId + "\",\""+ row.typeInsurance2 + "\",\""+ row.capitalChannelStatus + "\",\""+ row.channelTBStatus + "\",\""+ row.opponent + "\",\""+ row.tradeType + "\")' class='btn-link'>退保结算</a>&nbsp;&nbsp;&nbsp;&nbsp;"
                        </shiro:hasPermission>
                        return html;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 5,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var type =  row.typeInsurance;
                        var html = "商业险";
                        if('0'==type){
                            html = "交强险";
                        }
                        return html;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 3,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var type =  row.channelType;
                        var html =  row.channelCName;
                        if('1'==type){
                            html = row.channelPName;
                        }
                        return html;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 0,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var ordNum =  row.ordNum;
                        var id = '"' + row.tid + '"';
                        var html = "<a href='javascript:void(0);'   onclick='detail("+ id + ")'  class='btn-link'>"+row.ordNum+"</a>"
                        return html;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 23,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var amt1 =  row.mustRebateAmt;
                        var amt2 =  row.mustPremium;
                        if(amt1==null){
                            amt1 = 0;
                        }
                        if(amt2==null){
                            amt2 = 0;
                        }
                        var amt = parseFloat(amt2)+parseFloat(amt1);
                        return amt;
                    }
                },{
                    // 定义操作列,######以下是重点########
                    "targets" : 1,//是操作按钮目标列
                    "data" : null,
                    "render" : function(data, type,row) {
                        var type =  ""+row.paySubject;
                        var html = "--";
                        for(var i=0;i<dic.length;i++){
                            var dics = ""+dic[i][0];
                            if(type==dics){
                                html = dic[i][1];
                            }
                        }
                        return html;
                    }
                }]

            } );
        } );
        function search1(){
            table1.ajax.reload();
        }
        function search2(){
            table2.ajax.reload();
        }
        function download1(){debugger;
            var insyrerId = $('#insyrerIdSerch').val();
            var ordNum = $('#ordNumSerch').val();
            var channelId = $('#channelIdSerch').val();
            var dateIssuanceStart = $('#dateIssuanceStartSerch').val();
            var dateIssuanceEnd = $('#dateIssuanceEndSerch').val();
            var surrenderDateStart = $('#surrenderDateStartSerch').val();
            var surrenderDateEnd = $('#surrenderDateEndSerch').val();
            window.location.href="<%=path%>/repaying/downloadi?capitalStatus=1&insyrerId="+insyrerId+"&ordNum="+ordNum
                +"&channelId="+channelId+"&dateIssuanceStart="+dateIssuanceStart+"&dateIssuanceEnd="+dateIssuanceEnd
                +"&surrenderDateStart="+surrenderDateStart+"&surrenderDateEnd="+surrenderDateEnd;
            $("#subButtonYes").removeAttrs("onclick");
            $("#modal-subInfo").modal('hide');
            /*var tData ={};
            //添加额外的参数传给服务器
            tData.capitalStatus = 1;
            tData.insyrerId = insyrerId;
            tData.ordNum = ordNum;
            tData.channelId = channelId;
            tData.dateIssuanceStart = dateIssuanceStart;
            tData.dateIssuanceEnd = dateIssuanceEnd;
            tData.surrenderDateStart = surrenderDateStart;
            tData.surrenderDateEnd = surrenderDateEnd;
            jQuery.ajax({
                type: "POST",
                url: "< %=path%>/repaying/downloadi",
                data:tData,
                success: function (data) {

                }
            });*/
        }
        function download2(){
            var insyrerId = $('#insyrerIdCSerch').val();
            var ordNum = $('#ordNumCSerch').val();
            var channelId = $('#channelIdCSerch').val();
            var dateIssuanceStart = $('#dateIssuanceStartCSerch').val();
            var dateIssuanceEnd = $('#dateIssuanceEndCSerch').val();
            var surrenderDateStart = $('#surrenderDateStartCSerch').val();
            var surrenderDateEnd = $('#surrenderDateEndCSerch').val();
            window.location.href="<%=path%>/repaying/downloadc?capitalStatus=3&insyrerId="+insyrerId+"&ordNum="+ordNum
                +"&channelId="+channelId+"&dateIssuanceStart="+dateIssuanceStart+"&dateIssuanceEnd="+dateIssuanceEnd
                +"&surrenderDateStart="+surrenderDateStart+"&surrenderDateEnd="+surrenderDateEnd;
            $("#subButtonYes").removeAttrs("onclick");
            $("#modal-subInfo").modal('hide');
        }
        //改变下载路径
        function changeUrl(type) {
            if(type==2){
                $("#down1").parent().removeClass("hidden");
                $("#down").parent().addClass("hidden");
            }else{
                $("#down").parent().removeClass("hidden");
                $("#down1").parent().addClass("hidden");
            }
            var i = 0;
            $("#repayTabs").find("li").each(function(){
                if(i>3){
                    $(this).remove();
                }
                i++;
            });
        }
        function openModel(type){
            if(type==2){
                $("#showSubInfo").html("确认下载当前列表信息？");
                $("#subButtonYes").attr("onclick","download2();");
                $("#modal-subInfo").modal('show');
            }else{
                $("#showSubInfo").html("确认下载当前列表信息？");
                $("#subButtonYes").attr("onclick","download1();");
                $("#modal-subInfo").modal('show');
            }
        }
        $("#channelNameSerch").keyup(function () {
            var name = $("#channelNameSerch").val();
            if(name!=null&&name!=""){
                $("#chs").html("");
                $("#channelIdSerch").val("");
                $.ajax({
                    url:"/channel/findAllChannelName/"+name,
                    data:{},
                    type:"get",
                    success:function (data) {
                        if(data.success){
                            var channelIds = "";
                            var chHtml = "";
                            for (var i in data.result){
                                console.log("companyRegisterName--------"+data.result[i].companyRegisterName);

                                if(data.result[i].companyRegisterName!=null){
                                    chHtml += '<li value='+data.result[i].tid+'>'+data.result[i].companyRegisterName+'</li>';
                                }else{
                                    chHtml += '<li value='+data.result[i].tid+'>'+data.result[i].contact.name+'</li>';
                                }
                                channelIds += "," + data.result[i].tid;
                            }
                            /*var width = parseInt($("#channel").width());*/
                            if(channelIds!=null&&channelIds!=""){
                                channelIds = channelIds.substring(1,channelIds.length);
                            }else{
                                channelIds = -1;
                            }
                            $("#chs").html(chHtml);
                            $("#chs").parent().addClass("open");
                            $("#channelIdSerch").val(channelIds);
                            $("#chs li").click(function () {
                                $("#channelNameSerch").val($(this).html());
                                $("#channelIdSerch").val($(this).val());
                            })

                        }else{
                            $("#channelIdSerch").val(-1);
                        }
                    },
                    dataType:"json"
                })
            }else{
                $("#channelIdSerch").val("");
                $("#chs li").remove();
            }
        })
        $("#channelNameCSerch").keyup(function () {
            var name = $("#channelNameCSerch").val();
            if(name!=null&&name!=""){
                $("#chc").html("");
                $("#channelIdCSerch").val("");
                $.ajax({
                    url:"/channel/findAllChannelName/"+name,
                    data:{},
                    type:"get",
                    success:function (data) {
                        if(data.success){
                            var channelIds = "";
                            var chHtml = "";
                            for (var i in data.result){
                                console.log("companyRegisterName--------"+data.result[i].companyRegisterName);

                                if(data.result[i].companyRegisterName!=null){
                                    chHtml += '<li value='+data.result[i].tid+'>'+data.result[i].companyRegisterName+'</li>';
                                }else{
                                    chHtml += '<li value='+data.result[i].tid+'>'+data.result[i].contact.name+'</li>';
                                }
                                channelIds += "," + data.result[i].tid;
                            }
                            /*var width = parseInt($("#channel").width());*/
                            if(channelIds!=null&&channelIds!=""){
                                channelIds = channelIds.substring(1,channelIds.length);
                            }else{
                                channelIds = -1;
                            }
                            $("#chc").html(chHtml);
                            $("#chc").parent().addClass("open");
                            $("#channelIdSerch").val(channelIds);
                            $("#chc li").click(function () {
                                $("#channelNameCSerch").val($(this).html());
                                $("#channelIdCSerch").val($(this).val());
                            })

                        }else{
                            $("#channelIdCSerch").val(-1);
                        }
                    },
                    dataType:"json"
                })
            }else{
                $("#channelIdCSerch").val("");
                $("#chs li").remove();
            }
        })
        /*function setIframeHeight(iframe) {
            if (iframe) {
                var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
                if (iframeWin.document.body) {
                    iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
                }
            }
        };*/




        function detail(orderId) {
            $("#repayTabs").find("li").each(function(){
                $(this).removeClass("active");
            });
            $("#repayTabs").append('<li class="active"><a href="#default-tab-3" data-toggle="tab">保单详情</a></li>');
            $("#default-tab-1").removeClass("active in");
            $("#default-tab-2").removeClass("active in");
            $("#default-tab-3").addClass("active in");
            $("#iframe").attr("src","/ins/order/orderInfoDetail?tid="+orderId);
           /* setTimeout(function(){
                console.log(23456);
                setIframeHeight(document.getElementById('iframe'));
            },2000)*/
        }
    </script>
</body>
</html>
